<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="head.jsp" %>
<title>填写行程单信息</title>
<style>
#errorMsg{color: #D35714;}
select{width: 150px}
.none{display: none; padding-left: 20px}
</style>
<script type="text/javascript" src="script/regval.js"></script>
</head>
<body>
<div class="title">邮寄行程单</div>
<form action="person_addItin.shtml" method="post">
	<ul class="radius_border box_form">
		<li>
			<span>省</span>
			<input name="travel.province" id="txt_province" type="hidden" value="" />
			<select name="province" id="province"></select>
		</li>
		<li>
			<span>市</span>
			<input name="travel.city" id="txt_city" type="hidden" value="" />
			<select name="city" id="city"></select>
		</li>
		<li>
			<span>地址</span>
			<input name="travel.address" id="address" width="150px" />
		</li>
		<li>
			<span>收件人</span>
			<input name="travel.name" id="name" />
		</li>
		<li>
			<span>电话</span>
			<input name="travel.phone" id="phone" maxlength="13" />
		</li>
		<li>
			<span>邮编</span>
			<input name="travel.zip" id="zip" maxlength="6" />
		</li>
	</ul>
	<ul class="radius_border box_form" id="errorMsg">
	</ul>
		<div align="center">
			<button type="submit" onclick="return valform();" class="next_button">下一步</button>
		</div>
</form>
</body>
<script type="text/javascript">
initData=function(id,pid,rt){
	$('#'+id).empty();
	$.ajax({
		type:'POST',
		url:'/region.shtml',
		data:{pid:pid,rt:rt},
		async:false,
		dataType:'json',
		success:function(data){
			$(data).each(function(i){
				$('#'+id).append("<option value='"+data[i].region_id+"'>"+data[i].region_name+"</option>");
			});
		}
	});
};
initData('province',0,1);
initData('city',$('#province').val(),2);
$('#province').bind('change',function(){
	initData('city',$(this).val(),2);
});
valform=function(){
	$('#errorMsg').hide();
	var address = $.trim($('#address').val());
	var name = $.trim($('#name').val());
	var phone = $.trim($('#phone').val());
	var zip = $.trim($('#zip').val());
	if(address==''){error_msg('地址不能为空!');return false;}
	if(name==''){error_msg('收件人不能为空!');return false;}
	if(phone==''){error_msg('联系电话不能为空!');return false;}
	if(zip==''){error_msg('邮政编码不能为空!');return false;}
	initTextVal();
};
error_msg=function(msg){
	$('#errorMsg').html('<li>'+msg+'</li>').show();
};
initTextVal=function(){
	$('#txt_city').val($.trim($('#city option:selected').text()));
	$('#txt_province').val($.trim($('#province option:selected').text()));
}
</script>
</html>